package org.lakesidecdc.outreach.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.datepicker.client.DatePicker;

public class AddEventPanel extends Widget implements ClickHandler {

	private PopupPanel popup = new PopupPanel();
	private FlexTable table = new FlexTable();
	private DatePicker dateBox = new DatePicker();
	private TextBox volunteerHoursBox = new TextBox();
	private TextBox staffHoursBox = new TextBox();
	private TextBox expendituresBox = new TextBox();
	private Button saveButton = new Button("Save");
	
	public AddEventPanel() {
		// set up format
		table.setText(0, 0, "Date: ");
		table.setWidget(0, 1, dateBox);
		table.setText(1, 0, "Volunteer Hours: ");
		table.setWidget(1, 1, volunteerHoursBox);
		table.setText(2, 0, "Staff Hours: ");
		table.setWidget(2, 1, staffHoursBox);
		table.setText(3, 0, "Expenditures: ");
		table.setWidget(3, 1, expendituresBox);
		table.setWidget(4, 1, saveButton);
		
		popup.add(table);
		
		// Listen for clicks on the save button
		saveButton.addClickHandler(this);
	}
	
	public void show() {
		popup.show();
	}
	
	public void hide() {
		popup.hide();
	}
	
	public void onClick(ClickEvent event) {
		Object sender = event.getSource();
		if(sender == saveButton) {
//			addEvent();
			hide();
		} else {
			// do nothing
		}
	}
	
//	public void addEvent() {
//		LakesideOutreachManager.get().getCurrentEventList().add(new ProjectEvent(
//				Float.valueOf(volunteerHoursBox.getText()), 
//				Float.valueOf(staffHoursBox.getText()), 
//				Float.valueOf(expendituresBox.getText())));
//	}
}
